home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1150 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: cs.mu.OZ.AU!bounce-back
  2. From: Rob Stewart <stew@datalytics.com>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Use of standard exception classes
  5. Date: 18 Apr 96 00:54:30 GMT
  6. Organization: Datalytics, Inc
  7. Approved: fjh@cs.mu.oz.au
  8. Message-ID: <31756177.EB7@datalytics.com>
  9. References: <9604121530.AA08606@sun132.spd.dsccc.com> <BGLENDEN.96Apr12135956@colobus.aoc.nrao.edu>
  10. NNTP-Posting-Host: mundook.cs.mu.oz.au
  11. X-Original-Date: Wed, 17 Apr 1996 17:24:07 -0400
  12. X-Mailer: Mozilla 2.0 (WinNT; I)
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBFAgUBMXWSzOEDnX0m9pzZAQETwwF9FGCpj5Zh8nI6u/ST1ImUnBaUs3Qiuh+8
  15.     JN+5WxgRXNXv+SfbgG4RnShuezDPSKig
  16.     =apeb
  17. Originator: fjh@mundook.cs.mu.OZ.AU
  18.  
  19. Brian Glendenning wrote:
  20. > In a different topic, I'm confused about the different purpose ascribed to
  21. > exceptions derived from logic_error:
  22. > [snip]
  23. > and runtime_error:
  24. > [snip]
  25. > It seems to me that with this wording most exceptions should be derived from
  26. > runtime_error.
  27. > However, basic_string<...>::remove(size_type pos = 0, size_type n = npos),
  28. > for example, throws out_of_range (derived from logic error).
  29. > Unless the program only runs with manifest constants, it can't detect this
  30. > problem before the program executs:
  31. >         cin >> pos; mystring.remove(pos);
  32. > So why does it throw a logic_error rather than a runtime_error? Thanks!
  33. > (I'm also interested in learning whether it's a good idea to derive our
  34. > exceptions from standard exceptions).
  35.  
  36. Your code should have encountered that condition during 
  37. development, or you should have seen it coming, so you should 
  38. have logic built in to supply correct values to remove in all 
  39. cases.
  40.  
  41. -- 
  42. Robert Stewart        | My opinions are usually my own.
  43. Datalytics, Inc.    | stew@datalytics.com
  44. ---
  45. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  46. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  47. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  48. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  49. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  50.